package cn.ffcs.uec.wBStaffInfo.action;


import java.io.IOException;
import java.text.ParseException;
import java.util.List;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.ListModelList;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.raptornuke.portal.kernel.xml.DocumentException;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.outStaff.manager.UecOutStaffContractManager;
import cn.ffcs.uec.outStaff.manager.UecOutStaffInfomationManager;
import cn.ffcs.uec.outStaff.manager.UecOutStaffManager;
import cn.ffcs.uec.outStaff.model.UecOutStaffContract;
import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaff.vo.UecOutStaffInfomationVo;
import cn.ffcs.uec.wBStaffInfo.action.bean.UecOutStaffInfoContractBean;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.util.UomZkUtil;
import cn.ffcs.uom.common.vo.PageInfo;
/**
 * 外包自助合同信息
 * @author BMP
 * @time 2019-1-19
 */
@Controller
@Scope("prototype")
public class WbStaffInfoContractMainComposer extends BasePortletComposer implements
		IPortletInfoProvider {
	private static final long serialVersionUID = -5929030282722775845L;
	private UecOutStaffContractManager uecOutStaffContractManager = (UecOutStaffContractManager) ApplicationContextUtil
			.getBean("uecOutStaffContractManager");
	 private UecOutStaffInfomationVo uecOutStaffInfomationVo = new UecOutStaffInfomationVo();
	 private UecOutStaffInfomationManager uecOutStaffInfomationManager = (UecOutStaffInfomationManager) ApplicationContextUtil
				.getBean("uecOutStaffInfomationManager");
	 private UecOutStaffManager uecOutStaffInfoManager = (UecOutStaffManager) ApplicationContextUtil
				.getBean("uecOutStaffManager");
	private UecOutStaffInfoContractBean bean = new UecOutStaffInfoContractBean();
	@Override
	public String getPortletId() {
		return super.getPortletId();
	}

	@Override
	public ThemeDisplay getThemeDisplay() {
		return super.getThemeDisplay();
	}

	@Override
	public void doAfterCompose(Component comp) throws Exception {
		super.doAfterCompose(comp);
		UomZkUtil.autoFitHeight(comp);
		Components.wireVariables(comp, bean);
	}
	/**
	 * 初始化窗口
	 * @throws ParseException 
	 * @throws com.itextpdf.text.DocumentException 
	 * @throws IOException 
	 * @throws DocumentException 
	 */
	public void onCreate$wbStaffInfoContractMainWin() throws ParseException {
		onQueryUecOutStaffInfoContractVo();
	}

	/**
	 * 取消
	 */
	public void onCancel() {
		this.bean.getWbStaffInfoContractMainWin().onClose();
	}
	
	/**
	 * 查询--uecOutStaffInfoVo
	 * @throws ParseException 
	 */
	@SuppressWarnings("unchecked")
	public void onQueryUecOutStaffInfoContractVo() throws ParseException {
			int activePage = bean.getUecOutContractListboxPaging().getActivePage();
			int pageSize = bean.getUecOutContractListboxPaging().getPageSize();
			// 外包合同
			UecOutStaffInfo uecOutStaffInfo= new UecOutStaffInfo();
			if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
				ZkUtil.showError("当前登录用户不存在!", "错误提示");
				return;
			} else {
				String screenName = PlatformUtil.getCurrentUser().getScreenName();
				uecOutStaffInfomationVo.setPsnCode(screenName.toUpperCase());
				uecOutStaffInfomationVo = uecOutStaffInfomationManager
						.qryUecOutStaffContractByUecOutStaffInfo(uecOutStaffInfomationVo);
			}
			UecOutStaffInfo findUecOutStaffInfo=new UecOutStaffInfo();
			if (uecOutStaffInfomationVo != null) {
				uecOutStaffInfo.setOutStaffId(uecOutStaffInfomationVo
						.getOutStaffId());
				findUecOutStaffInfo = uecOutStaffInfoManager.findUecOutStaffInfo(uecOutStaffInfo);
			}
			PageInfo pageInfo = uecOutStaffContractManager.queryPageInfoByUecOutStaffContract(findUecOutStaffInfo, activePage, pageSize);
			List<UecOutStaffContract> dataList2 = pageInfo.getDataList();
			ListModelList dataList = new BindingListModelList(dataList2, true);
			bean.getUecOutStaffContractListbox().setModel(dataList);
			bean.getUecOutContractListboxPaging().setTotalSize(pageInfo.getTotalCount());
	}

	/**
	 * 翻页
	 * @throws ParseException 
	 */
	public void onUecOutAssListboxPaging() throws ParseException {
			this.onQueryUecOutStaffInfoContractVo();
	}
	
	
	 
		 
}
